package com.wang.web3.contracts;

import org.web3j.abi.EventEncoder;
import org.web3j.abi.EventValues;
import org.web3j.abi.TypeReference;
import org.web3j.abi.datatypes.Address;
import org.web3j.abi.datatypes.Bool;
import org.web3j.abi.datatypes.Event;
import org.web3j.abi.datatypes.Function;
import org.web3j.abi.datatypes.Type;
import org.web3j.abi.datatypes.generated.Uint16;
import org.web3j.abi.datatypes.generated.Uint256;
import org.web3j.abi.datatypes.generated.Uint32;
import org.web3j.abi.datatypes.generated.Uint64;
import org.web3j.crypto.Credentials;
import org.web3j.protocol.Web3j;
import org.web3j.protocol.core.DefaultBlockParameter;
import org.web3j.protocol.core.RemoteCall;
import org.web3j.protocol.core.methods.request.EthFilter;
import org.web3j.protocol.core.methods.response.Log;
import org.web3j.protocol.core.methods.response.TransactionReceipt;
import org.web3j.tuples.generated.Tuple9;
import org.web3j.tx.Contract;
import org.web3j.tx.TransactionManager;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.Callable;

import rx.Observable;
import rx.functions.Func1;

/**
 * <p>Auto generated code.
 * <p><strong>Do not modify!</strong>
 * <p>Please use the <a href="https://docs.web3j.io/command_line.html">web3j command line tools</a>,
 * or the org.web3j.codegen.SolidityFunctionWrapperGenerator in the 
 * <a href="https://github.com/web3j/web3j/tree/master/codegen">codegen module</a> to update.
 *
 * <p>Generated with web3j version 3.2.0.
 */
public class KittyBase extends Contract {
    private static final String BINARY = "0x60606040526000600260146101000a81548160ff0219169083151502179055506101c060405190810160405280603c63ffffffff1663ffffffff168152602001607863ffffffff1663ffffffff16815260200161012c63ffffffff1663ffffffff16815260200161025863ffffffff1663ffffffff16815260200161070863ffffffff1663ffffffff168152602001610e1063ffffffff1663ffffffff168152602001611c2063ffffffff1663ffffffff16815260200161384063ffffffff1663ffffffff16815260200161708063ffffffff1663ffffffff16815260200161e10063ffffffff1663ffffffff1681526020016201518063ffffffff1663ffffffff1681526020016202a30063ffffffff1663ffffffff1681526020016205460063ffffffff1663ffffffff16815260200162093a8063ffffffff1663ffffffff16815250600390600e6200015692919062000169565b5034156200016357600080fd5b62000249565b82600e600701600890048101928215620002005791602002820160005b83821115620001cc57835183826101000a81548163ffffffff021916908363ffffffff160217905550926020019260040160208160030104928301926001030262000186565b8015620001fe5782816101000a81549063ffffffff0219169055600401602081600301049283019260010302620001cc565b505b5090506200020f919062000213565b5090565b6200024691905b808211156200024257600081816101000a81549063ffffffff0219169055506001016200021a565b5090565b90565b61197380620002596000396000f3006060604052600436106100fc576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630519ce79146101015780630a0f816814610156578063133da607146101ab57806327d7874c1461020e5780632ba73c15146102475780633f4ba83a1461028057806346116e6f14610295578063481af3d3146102f85780634e0a33791461035b5780635c975abb146103945780635fd8c710146103c15780636f57d2e9146103d65780638456cb591461040b5780638cc51eda146104205780639d6fac6f146104f3578063a25905a914610536578063a45f4bfc1461055f578063b047fb50146105c2575b600080fd5b341561010c57600080fd5b610114610617565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561016157600080fd5b61016961063d565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156101b657600080fd5b61020c600480803590602001909190803590602001908201803590602001908080602002602001604051908101604052809392919081815260200183836020028082843782019150505050505091905050610662565b005b341561021957600080fd5b610245600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506108f7565b005b341561025257600080fd5b61027e600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506109d1565b005b341561028b57600080fd5b610293610aac565b005b34156102a057600080fd5b6102b66004808035906020019091905050610b3f565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561030357600080fd5b6103196004808035906020019091905050610b72565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561036657600080fd5b610392600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610ba5565b005b341561039f57600080fd5b6103a7610c80565b604051808215151515815260200191505060405180910390f35b34156103cc57600080fd5b6103d4610c93565b005b34156103e157600080fd5b6104096004808035906020019091908035906020019091908035906020019091905050610d6a565b005b341561041657600080fd5b61041e610f6f565b005b341561042b57600080fd5b61044160048080359060200190919050506110b3565b604051808a81526020018967ffffffffffffffff1667ffffffffffffffff1681526020018867ffffffffffffffff1667ffffffffffffffff1681526020018763ffffffff1663ffffffff1681526020018663ffffffff1663ffffffff1681526020018563ffffffff1663ffffffff1681526020018461ffff1661ffff1681526020018361ffff1661ffff1681526020018261ffff1661ffff168152602001995050505050505050505060405180910390f35b34156104fe57600080fd5b6105146004808035906020019091905050611192565b604051808263ffffffff1663ffffffff16815260200191505060405180910390f35b341561054157600080fd5b6105496111c1565b6040518082815260200191505060405180910390f35b341561056a57600080fd5b61058060048080359060200190919050506111ce565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156105cd57600080fd5b6105d5611201565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000806000806000803373ffffffffffffffffffffffffffffffffffffffff16600660008a815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415156106d857600080fd5b60009550600a94506005888154811015156106ef57fe5b90600052602060002090600302019350600092505b865183101561087c573373ffffffffffffffffffffffffffffffffffffffff1660066000898681518110151561073657fe5b90602001906020020151815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141561086f576005878481518110151561079b57fe5b906020019060200201518154811015156107b157fe5b906000526020600020906003020160020160009054906101000a900461ffff1661ffff168460020160009054906101000a900461ffff1661ffff1614156107fc57848601955061086e565b846005888581518110151561080d57fe5b9060200190602002015181548110151561082357fe5b906000526020600020906003020160020160009054906101000a900461ffff168560020160009054906101000a900461ffff160361ffff168603860281151561086857fe5b04860195505b5b8280600101935050610704565b6001600a60014303406001900481151561089257fe5b06019150600a868115156108a257fe5b04600a0390506108b187611227565b808211156108ed5760018460020160008282829054906101000a900461ffff160192506101000a81548161ffff021916908361ffff1602179055505b5050505050505050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561095257600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415151561098e57600080fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610a2c57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614151515610a6857600080fd5b80600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610b0757600080fd5b600260149054906101000a900460ff161515610b2257600080fd5b6000600260146101000a81548160ff021916908315150217905550565b60096020528060005260406000206000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60086020528060005260406000206000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610c0057600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614151515610c3c57600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600260149054906101000a900460ff1681565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610cef57600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc3073ffffffffffffffffffffffffffffffffffffffff16319081150290604051600060405180830381858888f193505050501515610d6857600080fd5b565b6000803373ffffffffffffffffffffffffffffffffffffffff166006600087815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141515610dda57600080fd5b3373ffffffffffffffffffffffffffffffffffffffff166006600086815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141515610e4757600080fd5b600585815481101515610e5657fe5b906000526020600020906003020191504267ffffffffffffffff168260010160089054906101000a900467ffffffffffffffff1667ffffffffffffffff16101515610ea057600080fd5b600584815481101515610eaf57fe5b906000526020600020906003020190504267ffffffffffffffff168160010160089054906101000a900467ffffffffffffffff1667ffffffffffffffff16101515610ef957600080fd5b6201518042018260010160086101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055506201518042018160010160086101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550610f678585600086336112e2565b505050505050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16148061101757506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b8061106f5750600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b151561107a57600080fd5b600260149054906101000a900460ff1615151561109657600080fd5b6001600260146101000a81548160ff021916908315150217905550565b6005818154811015156110c257fe5b90600052602060002090600302016000915090508060000154908060010160009054906101000a900467ffffffffffffffff16908060010160089054906101000a900467ffffffffffffffff16908060010160109054906101000a900463ffffffff16908060010160149054906101000a900463ffffffff16908060010160189054906101000a900463ffffffff169080600101601c9054906101000a900461ffff169080600101601e9054906101000a900461ffff16908060020160009054906101000a900461ffff16905089565b600381600e811015156111a157fe5b60089182820401919006600402915054906101000a900463ffffffff1681565b6000600580549050905090565b60066020528060005260406000206000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008090505b81518110156112905760066000838381518110151561124857fe5b90602001906020020151815260200190815260200160002060006101000a81549073ffffffffffffffffffffffffffffffffffffffff0219169055808060010191505061122d565b8151600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055505050565b60006112ec6117b5565b600063ffffffff881115151561130157600080fd5b63ffffffff871115151561131457600080fd5b61ffff861115151561132557600080fd5b610120604051908101604052808681526020014267ffffffffffffffff168152602001600067ffffffffffffffff1681526020018963ffffffff1681526020018863ffffffff168152602001600063ffffffff168152602001600061ffff1681526020018761ffff168152602001600161ffff1681525091506001600580548060010182816113b49190611834565b916000526020600020906003020160008590919091506000820151816000015560208201518160010160006101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555060408201518160010160086101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555060608201518160010160106101000a81548163ffffffff021916908363ffffffff16021790555060808201518160010160146101000a81548163ffffffff021916908363ffffffff16021790555060a08201518160010160186101000a81548163ffffffff021916908363ffffffff16021790555060c082015181600101601c6101000a81548161ffff021916908361ffff16021790555060e082015181600101601e6101000a81548161ffff021916908361ffff1602179055506101008201518160020160006101000a81548161ffff021916908361ffff160217905550505003905063ffffffff811115151561152957600080fd5b8373ffffffffffffffffffffffffffffffffffffffff167f0a5311bd2a6608f08a180df2ee7c5946819a649b204b554bb8e39825b2c50ad582846060015163ffffffff16856080015163ffffffff1686600001516040518085815260200184815260200183815260200182815260200194505050505060405180910390a26115b3600085836115c1565b809250505095945050505050565b600760008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008154809291906001019190505550816006600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614151561175557600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008154809291906001900391905055506009600082815260200190815260200160002060006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556008600082815260200190815260200160002060006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690555b808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b6101206040519081016040528060008152602001600067ffffffffffffffff168152602001600067ffffffffffffffff168152602001600063ffffffff168152602001600063ffffffff168152602001600063ffffffff168152602001600061ffff168152602001600061ffff168152602001600061ffff1681525090565b815481835581811511611861576003028160030283600052602060002091820191016118609190611866565b5b505050565b61194491905b80821115611940576000808201600090556001820160006101000a81549067ffffffffffffffff02191690556001820160086101000a81549067ffffffffffffffff02191690556001820160106101000a81549063ffffffff02191690556001820160146101000a81549063ffffffff02191690556001820160186101000a81549063ffffffff021916905560018201601c6101000a81549061ffff021916905560018201601e6101000a81549061ffff02191690556002820160006101000a81549061ffff02191690555060030161186c565b5090565b905600a165627a7a723058208887e79e6dcf564fad5a983237428975bd7be16c348865b065b5d95caae798330029";

    protected static final HashMap<String, String> _addresses;

    static {
        _addresses = new HashMap<>();
    }

    protected KittyBase(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
        super(BINARY, contractAddress, web3j, credentials, gasPrice, gasLimit);
    }

    protected KittyBase(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) {
        super(BINARY, contractAddress, web3j, transactionManager, gasPrice, gasLimit);
    }

    public List<BirthEventResponse> getBirthEvents(TransactionReceipt transactionReceipt) {
        final Event event = new Event("Birth", 
                Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}),
                Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}, new TypeReference<Uint256>() {}, new TypeReference<Uint256>() {}, new TypeReference<Uint256>() {}));
        List<EventValues> valueList = extractEventParameters(event, transactionReceipt);
        ArrayList<BirthEventResponse> responses = new ArrayList<BirthEventResponse>(valueList.size());
        for (EventValues eventValues : valueList) {
            BirthEventResponse typedResponse = new BirthEventResponse();
            typedResponse.owner = (String) eventValues.getIndexedValues().get(0).getValue();
            typedResponse.kittyId = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue();
            typedResponse.matronId = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue();
            typedResponse.sireId = (BigInteger) eventValues.getNonIndexedValues().get(2).getValue();
            typedResponse.genes = (BigInteger) eventValues.getNonIndexedValues().get(3).getValue();
            responses.add(typedResponse);
        }
        return responses;
    }

    public Observable<BirthEventResponse> birthEventObservable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
        final Event event = new Event("Birth", 
                Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}),
                Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}, new TypeReference<Uint256>() {}, new TypeReference<Uint256>() {}, new TypeReference<Uint256>() {}));
        EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress());
        filter.addSingleTopic(EventEncoder.encode(event));
        return web3j.ethLogObservable(filter).map(new Func1<Log, BirthEventResponse>() {
            @Override
            public BirthEventResponse call(Log log) {
                EventValues eventValues = extractEventParameters(event, log);
                BirthEventResponse typedResponse = new BirthEventResponse();
                typedResponse.owner = (String) eventValues.getIndexedValues().get(0).getValue();
                typedResponse.kittyId = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue();
                typedResponse.matronId = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue();
                typedResponse.sireId = (BigInteger) eventValues.getNonIndexedValues().get(2).getValue();
                typedResponse.genes = (BigInteger) eventValues.getNonIndexedValues().get(3).getValue();
                return typedResponse;
            }
        });
    }

    public List<TransferEventResponse> getTransferEvents(TransactionReceipt transactionReceipt) {
        final Event event = new Event("Transfer", 
                Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}, new TypeReference<Address>() {}, new TypeReference<Uint256>() {}),
                Arrays.<TypeReference<?>>asList());
        List<EventValues> valueList = extractEventParameters(event, transactionReceipt);
        ArrayList<TransferEventResponse> responses = new ArrayList<TransferEventResponse>(valueList.size());
        for (EventValues eventValues : valueList) {
            TransferEventResponse typedResponse = new TransferEventResponse();
            typedResponse.from = (String) eventValues.getIndexedValues().get(0).getValue();
            typedResponse.to = (String) eventValues.getIndexedValues().get(1).getValue();
            typedResponse.tokenId = (BigInteger) eventValues.getIndexedValues().get(2).getValue();
            responses.add(typedResponse);
        }
        return responses;
    }

    public Observable<TransferEventResponse> transferEventObservable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
        final Event event = new Event("Transfer", 
                Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}, new TypeReference<Address>() {}, new TypeReference<Uint256>() {}),
                Arrays.<TypeReference<?>>asList());
        EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress());
        filter.addSingleTopic(EventEncoder.encode(event));
        return web3j.ethLogObservable(filter).map(new Func1<Log, TransferEventResponse>() {
            @Override
            public TransferEventResponse call(Log log) {
                EventValues eventValues = extractEventParameters(event, log);
                TransferEventResponse typedResponse = new TransferEventResponse();
                typedResponse.from = (String) eventValues.getIndexedValues().get(0).getValue();
                typedResponse.to = (String) eventValues.getIndexedValues().get(1).getValue();
                typedResponse.tokenId = (BigInteger) eventValues.getIndexedValues().get(2).getValue();
                return typedResponse;
            }
        });
    }

    public List<ContractUpgradeEventResponse> getContractUpgradeEvents(TransactionReceipt transactionReceipt) {
        final Event event = new Event("ContractUpgrade", 
                Arrays.<TypeReference<?>>asList(),
                Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}));
        List<EventValues> valueList = extractEventParameters(event, transactionReceipt);
        ArrayList<ContractUpgradeEventResponse> responses = new ArrayList<ContractUpgradeEventResponse>(valueList.size());
        for (EventValues eventValues : valueList) {
            ContractUpgradeEventResponse typedResponse = new ContractUpgradeEventResponse();
            typedResponse.newContract = (String) eventValues.getNonIndexedValues().get(0).getValue();
            responses.add(typedResponse);
        }
        return responses;
    }

    public Observable<ContractUpgradeEventResponse> contractUpgradeEventObservable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
        final Event event = new Event("ContractUpgrade", 
                Arrays.<TypeReference<?>>asList(),
                Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}));
        EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress());
        filter.addSingleTopic(EventEncoder.encode(event));
        return web3j.ethLogObservable(filter).map(new Func1<Log, ContractUpgradeEventResponse>() {
            @Override
            public ContractUpgradeEventResponse call(Log log) {
                EventValues eventValues = extractEventParameters(event, log);
                ContractUpgradeEventResponse typedResponse = new ContractUpgradeEventResponse();
                typedResponse.newContract = (String) eventValues.getNonIndexedValues().get(0).getValue();
                return typedResponse;
            }
        });
    }

    public RemoteCall<String> cfoAddress() {
        Function function = new Function("cfoAddress", 
                Arrays.<Type>asList(), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}));
        return executeRemoteCallSingleValueReturn(function, String.class);
    }

    public RemoteCall<String> ceoAddress() {
        Function function = new Function("ceoAddress", 
                Arrays.<Type>asList(), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}));
        return executeRemoteCallSingleValueReturn(function, String.class);
    }

    public RemoteCall<TransactionReceipt> setCEO(String _newCEO) {
        Function function = new Function(
                "setCEO", 
                Arrays.<Type>asList(new Address(_newCEO)),
                Collections.<TypeReference<?>>emptyList());
        return executeRemoteCallTransaction(function);
    }

    public RemoteCall<TransactionReceipt> setCOO(String _newCOO) {
        Function function = new Function(
                "setCOO", 
                Arrays.<Type>asList(new Address(_newCOO)),
                Collections.<TypeReference<?>>emptyList());
        return executeRemoteCallTransaction(function);
    }

    public RemoteCall<TransactionReceipt> unpause() {
        Function function = new Function(
                "unpause", 
                Arrays.<Type>asList(), 
                Collections.<TypeReference<?>>emptyList());
        return executeRemoteCallTransaction(function);
    }

    public RemoteCall<String> sireAllowedToAddress(BigInteger param0) {
        Function function = new Function("sireAllowedToAddress", 
                Arrays.<Type>asList(new Uint256(param0)),
                Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}));
        return executeRemoteCallSingleValueReturn(function, String.class);
    }

    public RemoteCall<String> kittyIndexToApproved(BigInteger param0) {
        Function function = new Function("kittyIndexToApproved", 
                Arrays.<Type>asList(new Uint256(param0)),
                Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}));
        return executeRemoteCallSingleValueReturn(function, String.class);
    }

    public RemoteCall<TransactionReceipt> setCFO(String _newCFO) {
        Function function = new Function(
                "setCFO", 
                Arrays.<Type>asList(new Address(_newCFO)),
                Collections.<TypeReference<?>>emptyList());
        return executeRemoteCallTransaction(function);
    }

    public RemoteCall<Boolean> paused() {
        Function function = new Function("paused", 
                Arrays.<Type>asList(), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Bool>() {}));
        return executeRemoteCallSingleValueReturn(function, Boolean.class);
    }

    public RemoteCall<TransactionReceipt> withdrawBalance() {
        Function function = new Function(
                "withdrawBalance", 
                Arrays.<Type>asList(), 
                Collections.<TypeReference<?>>emptyList());
        return executeRemoteCallTransaction(function);
    }

    public RemoteCall<TransactionReceipt> pause() {
        Function function = new Function(
                "pause", 
                Arrays.<Type>asList(), 
                Collections.<TypeReference<?>>emptyList());
        return executeRemoteCallTransaction(function);
    }

    public RemoteCall<Tuple9<BigInteger, BigInteger, BigInteger, BigInteger, BigInteger, BigInteger, BigInteger, BigInteger, BigInteger>> kitties(BigInteger param0) {
        final Function function = new Function("kitties", 
                Arrays.<Type>asList(new Uint256(param0)),
                Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}, new TypeReference<Uint64>() {}, new TypeReference<Uint64>() {}, new TypeReference<Uint32>() {}, new TypeReference<Uint32>() {}, new TypeReference<Uint32>() {}, new TypeReference<Uint16>() {}, new TypeReference<Uint16>() {}, new TypeReference<Uint16>() {}));
        return new RemoteCall<Tuple9<BigInteger, BigInteger, BigInteger, BigInteger, BigInteger, BigInteger, BigInteger, BigInteger, BigInteger>>(
                new Callable<Tuple9<BigInteger, BigInteger, BigInteger, BigInteger, BigInteger, BigInteger, BigInteger, BigInteger, BigInteger>>() {
                    @Override
                    public Tuple9<BigInteger, BigInteger, BigInteger, BigInteger, BigInteger, BigInteger, BigInteger, BigInteger, BigInteger> call() throws Exception {
                        List<Type> results = executeCallMultipleValueReturn(function);;
                        return new Tuple9<BigInteger, BigInteger, BigInteger, BigInteger, BigInteger, BigInteger, BigInteger, BigInteger, BigInteger>(
                                (BigInteger) results.get(0).getValue(), 
                                (BigInteger) results.get(1).getValue(), 
                                (BigInteger) results.get(2).getValue(), 
                                (BigInteger) results.get(3).getValue(), 
                                (BigInteger) results.get(4).getValue(), 
                                (BigInteger) results.get(5).getValue(), 
                                (BigInteger) results.get(6).getValue(), 
                                (BigInteger) results.get(7).getValue(), 
                                (BigInteger) results.get(8).getValue());
                    }
                });
    }

    public RemoteCall<BigInteger> cooldowns(BigInteger param0) {
        Function function = new Function("cooldowns", 
                Arrays.<Type>asList(new Uint256(param0)),
                Arrays.<TypeReference<?>>asList(new TypeReference<Uint32>() {}));
        return executeRemoteCallSingleValueReturn(function, BigInteger.class);
    }

    public RemoteCall<String> kittyIndexToOwner(BigInteger param0) {
        Function function = new Function("kittyIndexToOwner", 
                Arrays.<Type>asList(new Uint256(param0)),
                Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}));
        return executeRemoteCallSingleValueReturn(function, String.class);
    }

    public RemoteCall<String> cooAddress() {
        Function function = new Function("cooAddress", 
                Arrays.<Type>asList(), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}));
        return executeRemoteCallSingleValueReturn(function, String.class);
    }

    public RemoteCall<BigInteger> getKittiesCount() {
        Function function = new Function("getKittiesCount", 
                Arrays.<Type>asList(), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}));
        return executeRemoteCallSingleValueReturn(function, BigInteger.class);
    }

    public RemoteCall<TransactionReceipt> doEnchant(BigInteger _target, List<BigInteger> _kittyIds) {
        Function function = new Function(
                "doEnchant", 
                Arrays.<Type>asList(new Uint256(_target),
                new org.web3j.abi.datatypes.DynamicArray<Uint256>(
                        org.web3j.abi.Utils.typeMap(_kittyIds, Uint256.class))),
                Collections.<TypeReference<?>>emptyList());
        return executeRemoteCallTransaction(function);
    }

    public RemoteCall<TransactionReceipt> summonGirl(BigInteger _leftGirlId, BigInteger _rightGirlId, BigInteger _genes) {
        Function function = new Function(
                "summonGirl", 
                Arrays.<Type>asList(new Uint256(_leftGirlId),
                new Uint256(_rightGirlId),
                new Uint256(_genes)),
                Collections.<TypeReference<?>>emptyList());
        return executeRemoteCallTransaction(function);
    }

    public static RemoteCall<KittyBase> deploy(Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
        return deployRemoteCall(KittyBase.class, web3j, credentials, gasPrice, gasLimit, BINARY, "");
    }

    public static RemoteCall<KittyBase> deploy(Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) {
        return deployRemoteCall(KittyBase.class, web3j, transactionManager, gasPrice, gasLimit, BINARY, "");
    }

    public static KittyBase load(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
        return new KittyBase(contractAddress, web3j, credentials, gasPrice, gasLimit);
    }

    public static KittyBase load(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) {
        return new KittyBase(contractAddress, web3j, transactionManager, gasPrice, gasLimit);
    }

    protected String getStaticDeployedAddress(String networkId) {
        return _addresses.get(networkId);
    }

    public static String getPreviouslyDeployedAddress(String networkId) {
        return _addresses.get(networkId);
    }

    public static class BirthEventResponse {
        public String owner;

        public BigInteger kittyId;

        public BigInteger matronId;

        public BigInteger sireId;

        public BigInteger genes;
    }

    public static class TransferEventResponse {
        public String from;

        public String to;

        public BigInteger tokenId;
    }

    public static class ContractUpgradeEventResponse {
        public String newContract;
    }
}
